package com.code.leetcode.offer;

/**
 * @author codeDorado
 * @version 1.0
 * @date 2020/7/30 20:51
 */
public class The14_1 {
    public int cuttingRope(int num) {
        if (num <= 3) return num - 1;
        int m = num / 3;
        int n = num % 3;
        if (n == 0) return (int) Math.pow(3, m);
        if (n == 2) return (int) Math.pow(3, m) * 2;
        return (int) Math.pow(3, m - 1) * 4;
    }
}
